<template>
  <view :style="themeColor">
    <view class="page">
      <view class="flex benben-position-layout flex flex-wrap align-center activateMembership_flex_0"
        :style="{height:(88+StatusBarRpx)+'rpx',paddingTop:StatusBarRpx+'rpx', }">
        <view class='flex flex-wrap align-center justify-between flex-sub activateMembership_fd0_0'>
          <view class='flex flex-wrap align-center activateMembership_fd0_0_c0' @tap.stop="handleJumpDiy"
            data-type="back" data-url="1">
            <text class='fu-iconfont2  activateMembership_fd0_0_c0_c0'>&#xE794;</text>
          </view>
          <view class='flex flex-wrap align-stretch justify-center'>
            <text class='activateMembership_fd0_0_c1_c0'>开通会员</text>
          </view>
          <view class='flex flex-wrap align-center justify-end activateMembership_fd0_0_c0'>
          </view>
        </view>

      </view>
      <view :style="{height: (88+StatusBarRpx)+'rpx'}"></view>
      <!---flex布局flex布局开始-->
      <view class="flex flex-direction flex-wrap align-stretch benben-flex-layout">
        <benben-select-diy ref="showSelectPopup1697523101202"
          class-name='flex flex-wrap align-center flex activateMembership_fd1_0' :items.sync="member"
          v-model="member_value" :label.sync="member_label" @change="changeLvFunc()" default-type="aid"
          default-label="name" :allow-cancel='false' type="radio" :disabled='false'>
          <template v-for='(item,key0) in member'>
            <view v-if="item.isSelected"
              class='flex flex-direction align-center justify-center flex activateMembership_fd1_0_c0' :key="key0"
              @tap="$refs.showSelectPopup1697523101202.tapHandle(key0)">
              <view class='flex flex-wrap align-center'>
                <text class='activateMembership_fd1_0_c0_c0_c0'>￥</text>
                <text class=' activateMembership_fd1_0_c0_c0_c1'>
                  <text class=' activateMembership_price1_fd1_0_c0_c0_c1'>{{ item.price | frontPrice }}</text>
                  <text class=' activateMembership_price2_fd1_0_c0_c0_c1'>{{ item.price | laterPrice }}</text>
                </text>
              </view>
              <view class='flex flex-wrap align-center activateMembership_fd1_0_c0_c1'>
                <text class='activateMembership_fd1_0_c0_c1_c0'>￥</text>
                <text class='activateMembership_fd1_0_c0_c1_c0'>{{item.original_price}}</text>
              </view>
              <view class='flex flex-wrap align-center justify-center activateMembership_fd1_0_c0_c2'>
                <text class='activateMembership_fd1_0_c0_c2_c0'>{{item.name}}</text>
              </view>
            </view>
            <view v-else class='flex flex-direction align-center justify-center flex activateMembership_fd1_0_c1'
              :key="key0" @tap="$refs.showSelectPopup1697523101202.tapHandle(key0)">
              <view class='flex flex-wrap align-center'>
                <text class='activateMembership_fd1_0_c0_c0_c0'>￥</text>
                <text class=' activateMembership_fd1_0_c0_c0_c1'>
                  <text class=' activateMembership_price1_fd1_0_c0_c0_c1'>{{ item.price | frontPrice }}</text>
                  <text class=' activateMembership_price2_fd1_0_c0_c0_c1'>{{ item.price | laterPrice }}</text>
                </text>
              </view>
              <view class='flex flex-wrap align-center activateMembership_fd1_0_c0_c1'>
                <text class='activateMembership_fd1_0_c0_c1_c0'>￥</text>
                <text class='activateMembership_fd1_0_c0_c1_c0'>{{item.original_price}}</text>
              </view>
              <view class='flex flex-wrap align-center justify-center activateMembership_fd1_0_c0_c2'>
                <text class='activateMembership_fd1_0_c0_c2_c0'>{{item.name}}</text>
              </view>
            </view>
          </template></benben-select-diy>
        <text class='activateMembership_fd1_1'>租借须知</text>
        <text class='activateMembership_fd1_2'>{{notice}}</text>
        <view class='flex flex-wrap align-center activateMembership_fd1_3'>
        </view>
        <view class='flex flex-wrap align-center justify-between activateMembership_fd1_4'>
          <text class='activateMembership_fd1_4_c0'>会员卡有效期</text>
          <view class='flex flex-wrap align-center'>
            <text class='activateMembership_fd1_4_c1_c0'>{{period}}</text>
            <text class='activateMembership_fd1_4_c1_c0'>天</text>
          </view>
        </view>
        <view class='flex flex-wrap align-center activateMembership_fd1_5' @tap.stop="handleJumpDiy"
          data-type="navigateTo" :data-url="`/pages/my/memberNotice/memberNotice?rule=1`">
          <text class='activateMembership_fd1_4_c0'>会员须知</text>
          <text class='activateMembership_fd1_4_c1_c0'>去查看</text>
          <image class='activateMembership_fd1_5_c2' mode="aspectFit" :src='STATIC_URL+"37.png"'></image>
        </view>
      </view>
      <view class="cance_xy">
        <image :src='STATIC_URL+"82.png"' mode="aspectFill" v-if="checked" @click="checkclick"></image>
        <image :src='STATIC_URL+"83.png"' mode="aspectFill" v-else @click="checkclick">
        </image>
        <text>阅读并同意 <text style="color: #4177DD;" @tap.stop="handleJumpDiy" data-type="navigateTo"
            :data-url="`/pages/dlzc/agreement/agreement?id=15`">《安全协议》</text></text>
      </view>
      <!---flex布局flex布局结束-->
      <view class="flex flex-wrap align-stretch justify-center benben-position-layout flex activateMembership_flex_2">
        <button class='activateMembership_fd2_0' @tap.stop="goPay" data-type="redirectTo"
          :data-url="`/pages/my/openingDetails/openingDetails?membervalue=${member_value}&memberlabel=${member_label}&price=${price}&notice=${notice}`">{{userlevel_id ? '立即续费' : '立即开通'}}</button>

      </view>
      <view :style="{height: '120rpx'}"></view>


    </view>
  </view>
</template>
<script>
  import {
    validate
  } from '@/common/utils/validate.js'
  export default {
    components: {},


    data() {
      return {
        "member": [],
        "member_value": "",
        "member_label": "",
        "notice": "",
        "period": "",
        price: '',
        userlevel_id: '',
        checked: false
      };
    },
    computed: {
      themeColor() {
        return this.$store.getters.themeColor
      },
      isLogin() {
        return this.$store.state.token == '' ? false : true;
      },
      userInfo: {
        get() {
          return this.$store.state.userInfo
        },
        set() {
          this.$store.commit('updateUserInfo', value)
        },
      },
    },
    watch: {},
    onLoad(options) {

    },
    onUnload() {

    },
    onReady() {

    },
    onShow() {
      this.queryMessageFunc()
      this.getGradeFunc()
    },
    onHide() {

    },
    onResize() {

    },
    onPullDownRefresh() {

    },
    onReachBottom(e) {

    },
    onPageScroll(e) {

    },
    methods: {
      //协议选中状态
      checkclick() {
        this.checked = !this.checked;
      },
      goPay() {
        if (!this.checked) {
          this.$message.info('请勾选安全协议')
          return;
        }
        uni.redirectTo({
          url: `/pages/my/openingDetails/openingDetails?membervalue=${this.member_value}&memberlabel=${this.member_label}&price=${this.price}&notice=${this.notice}`
        })
      },
      async queryMessageFunc() {
        if (this.isLogin === true) {
          //请求方法
          //数据验证

          let datadataMessage = await this.$api.post(global.apiUrls.post5c78c4772da97, {
            user_id: this.userInfo.id
          });

          if (datadataMessage.data.code != 1) {
            this.$message.info(datadataMessage.data.msg);
            return
          }
          let infodataMessage = datadataMessage.data;
          this.userlevel_id = infodataMessage.data.userlevel_id
          console.log('userlevel_id', this.userlevel_id)
        }
      },
      //获取会员等级
      async getGradeFunc() {
        //请求方法
        //数据验证

        let datamember = await this.$api.get(global.apiUrls.post6536185d5da32, {

        });

        if (datamember.data.code != 1) {
          this.$message.info(datamember.data.msg);
          return
        }
        let infomember = datamember.data;
        this.member = infomember.data
        this.changeLvFunc()
      },
      //改变等级
      changeLvFunc() {
        let item = this.member.find(val => val.aid == this.member_value);
        if (!item) {
          this.member_value = this.member[0].aid;
          item = this.member[0];
        }
        this.period = item.day;
        this.price = item.price;
        this.notice = item.content;
      }
    }
  };
</script>
<style lang="scss" scoped>
  .cance_xy {
    width: 100%;
    height: auto;
    text-align: center;
    position: fixed;
    left: 0;
    bottom: 150rpx;
  }

  .cance_xy image {
    width: 32rpx;
    height: 32rpx;
    margin-right: 10rpx;
    position: relative;
    top: 4rpx;
  }

  .page {
    width: 100vw;
    overflow-x: hidden;
    min-height: calc(100vh - var(--window-bottom));
    background: url(https://api.nongjugongxiang.com/nongju/images/36.png) no-repeat, #FFFFFF;
    background-size: 100% auto;
  }

  .activateMembership_flex_0 {
    background: url(https://api.nongjugongxiang.com/nongju/images/36.png) no-repeat;
    width: 750rpx;
    height: 88rpx;
    overflow: hidden;
    z-index: 10;
    top: 0rpx;
    background-size: 100% auto !important;
  }

  .activateMembership_fd0_0_c1_c0 {
    font-size: 36rpx;
    font-weight: 500;
    color: #333;
    line-height: 88rpx;
  }

  .activateMembership_fd0_0_c0_c0 {
    font-size: 36rpx;
    color: #333;
    font-weight: 600;
  }

  .activateMembership_fd0_0_c0 {
    width: 120rpx;
  }

  .activateMembership_fd0_0 {
    padding: 0rpx 32rpx 0rpx 32rpx;
  }

  .activateMembership_fd1_5_c2 {
    width: 40rpx;
    height: 40rpx;
  }

  .activateMembership_fd1_5 {
    margin: 0rpx 32rpx 0rpx 32rpx;
    padding: 32rpx 0rpx 32rpx 0rpx;
  }

  .activateMembership_fd1_4_c1_c0 {
    margin: 0rpx 0rpx 0rpx auto;
    color: #E63838;
    font-size: 28rpx;
    font-weight: 400;
  }

  .activateMembership_fd1_4_c0 {
    color: #333333;
    font-size: 28rpx;
    font-weight: 400;
  }

  .activateMembership_fd1_4 {
    border-bottom: 1px solid #eee;
    margin: 0rpx 32rpx 0rpx 32rpx;
    padding: 32rpx 0rpx 32rpx 0rpx;
  }

  .activateMembership_fd1_3 {
    background: #F8F8F8;
    border-radius: 0rpx 0rpx 0rpx 0rpx;
    width: 750rpx;
    height: 16rpx;
  }

  .activateMembership_fd1_2 {
    margin: 16rpx 0rpx 32rpx 32rpx;
    color: #666666;
    font-size: 28rpx;
    font-weight: 400;
  }

  .activateMembership_fd1_1 {
    margin: 0rpx 0rpx 0rpx 32rpx;
    color: #333333;
    font-size: 28rpx;
    font-weight: 500;
  }

  .activateMembership_fd1_0_c1 {
    border: 1px solid #EEEEEE;
    background: #FFFFFF;
    border-radius: 24rpx 24rpx 24rpx 24rpx;
    width: 216rpx;
    height: 181rpx;
    position: relative;
    margin: 0rpx 19rpx 0rpx 0rpx;
  }

  .activateMembership_fd1_0_c0_c2_c0 {
    color: #FFFFFF;
    font-size: 28rpx;
    font-weight: 500;
  }

  .activateMembership_fd1_0_c0_c2 {
    background: #E63838;
    position: absolute;
    border-radius: 8rpx 8rpx 8rpx 8rpx;
    width: 76rpx;
    height: 40rpx;
    top: -18rpx;
    left: 66rpx;
    z-index: 0;
  }

  .activateMembership_fd1_0_c0_c1_c0 {
    color: rgba(153, 153, 153, 1);
    font-size: 24rpx;
    font-weight: 400;
    text-decoration: line-through;
  }

  .activateMembership_fd1_0_c0_c1 {
    margin: 16rpx 0rpx 0rpx 0rpx;
  }

  .activateMembership_price2_fd1_0_c0_c0_c1 {
    font-size: 36rpx;
    color: rgba(230, 56, 56, 1);
    font-weight: 700;
  }

  .activateMembership_price1_fd1_0_c0_c0_c1 {
    font-size: 36rpx;
  }

  .activateMembership_fd1_0_c0_c0_c1 {
    color: rgba(230, 56, 56, 1);
    font-weight: 700;
    font-size: 36rpx;
  }

  .activateMembership_fd1_0_c0_c0_c0 {
    color: rgba(230, 56, 56, 1);
    font-size: 24rpx;
    font-weight: 700;
  }

  .activateMembership_fd1_0_c0 {
    border: 2px solid #E63838;
    background: #FFE6E6;
    border-radius: 24rpx 24rpx 24rpx 24rpx;
    width: 216rpx;
    height: 181rpx;
    position: relative;
    margin: 0rpx 19rpx 0rpx 0rpx;
  }

  ::v-deep .activateMembership_fd1_0 {
    padding: 64rpx 13rpx 32rpx 32rpx;
  }

  .activateMembership_flex_2 {
    width: 750rpx;
    height: 120rpx;
    overflow: hidden;
    z-index: 10;
    bottom: calc(0rpx + var(--window-bottom));
  }

  .activateMembership_fd2_0 {
    background: #E63838;
    border-radius: 44rpx 44rpx 44rpx 44rpx;
    width: 702rpx;
    line-height: 88rpx;
    font-size: 32rpx;
    color: #fff;
    height: 88rpx;
  }
</style>